package com.alibaba.otter.shared.arbitrate.autoconfigure;

import com.alibaba.otter.shared.arbitrate.impl.interceptor.LogInterceptor;
import org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;

@Configuration(proxyBeanMethods = false)
public class ArbitrateLogConfiguration {


    @Bean
    public LogInterceptor logInterceptor() {
        return new LogInterceptor();
    }

    @Bean
    public BeanNameAutoProxyCreator beanNameAutoProxyCreator() {
        BeanNameAutoProxyCreator beanNameAutoProxyCreator = new BeanNameAutoProxyCreator();

        beanNameAutoProxyCreator.setInterceptorNames("logInterceptor");
        beanNameAutoProxyCreator.setProxyTargetClass(true);

        String[] beanNames = new String[]{
                "channelEvent",
                "pipelineEvent",
                "nodeEvent",
                "mainStemEvent",
                "selectEvent",
                "extractEvent",
                "transformEvent",
                "loadEvent",
                "terminEvent",
                "normalTerminProcess",
                "warningTerminProcess",
                "errorTerminProcess"
        };

        beanNameAutoProxyCreator.setBeanNames(beanNames);

        return beanNameAutoProxyCreator;
    }


}
